import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import configPrettier from 'eslint-config-prettier'
import pluginReact from 'eslint-plugin-react'

export default tseslint.config(
  { ignores: ['src/main.tsx','src/components/error/**/*.tsx',"vite.config.ts"] },
  {
    extends: [js.configs.recommended, ...tseslint.configs.recommended],
    files: ['**/*.{ts,tsx}'],
    languageOptions: {
      ecmaVersion: 2020,
      globals: globals.browser,
    },
    plugins: {
      'react-hooks': reactHooks,
      'react-refresh': reactRefresh,
    },
    rules: {
      "no-unused-vars": 2,//强制变量使用和定义检查
      // "no-undef": 2,//强制变量使用和定义检查
      "consistent-return": ["error", { "treatUndefinedAsUnspecified": true }],//统一函数返回一致性
      "eqeqeq": 2,//强制全等比较
      "curly": ["error", "multi-line"],//多行语句必须使用大括号
      "default-case": 1,//要求switch语句包含default分支
    }
  },
  configPrettier,// 禁用所有与 Prettier 冲突的 ESLint 规则
  pluginReact.configs.flat.recommended,
)
